class AddDomoicAcidWikipediaArticle < ActiveRecord::Migration
  def self.up
    chapter = Chapter.find_by_name("General information")
    toxin = Toxin.find_by_name("domoic acid")
    data_provider_wikipedia = DataProvider.create(:name=> "Wikipedia", 
    :risk_disclaimer=>"please be aware that any information you may find in wikipedia may be inaccurate, misleading, dangerous or illegal", 
    :logo=>"", :copyright_notice=>"This work is licensed under the <a href=\"http://en.wikipedia.org/wiki/Wikipedia:Text_of_the_GNU_Free_Documentation_License\">GFDL</a>", 
    :acknowledgement=>"From Wikipedia, the free encyclopedia",
    :home_url=>"http://en.wikipedia.org/wiki/Main_Page", :full_name=>"Wikipedia")
    taxon = Taxon.find_by_name("algae")
    location = Location.find_by_name("Earth")
    content = nil
    data_object = DataObject.create(:toxin=>toxin, :data_provider=>data_provider_wikipedia, 
    :bookend_start=>"Not applicable", :bookend_end=>"Not applicable", 
    :url=>"http://en.wikipedia.org/wiki/Domoic_acid", :taxon=>taxon, 
    :location=>location, :chapter=>chapter, :content=>content) 

  end

  def self.down
    #Delete the object first, then the provider!
    data_object_wikipedia_article = DataObject.find_by_url("http://en.wikipedia.org/wiki/Domoic_acid")
    data_object_wikipedia_article.destroy unless data_object_wikipedia_article.nil?

    data_provider_wikipedia = DataProvider.find_by_name("wikipedia")
    data_provider_wikipedia.destroy unless data_provider_wikipedia.nil? 
  end
end
